package cn.richard.demo.drools.web;

import java.time.LocalDateTime;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import cn.richard.demo.drools.core.AppDroolsConfigPropertiesBean;
import cn.richard.demo.drools.core.KieUtilService;
import cn.richard.demo.drools.dto.Tax;
import cn.richard.demo.drools.entity.PersonInfoEntity;

@RestController
public class TestCtrller {
	@Value("${spring.application.name}")
	private String app_name;

	@GetMapping("/hello")
	public Object hello() {
		return app_name + "@" + LocalDateTime.now().toString();
	}

	@Autowired
	private KieUtilService kieUtilService;
	@GetMapping("/rule/fire/personcheck")
	public Object ruleFire(PersonInfoEntity entity) {
		kieUtilService.fire(entity);
		// kieUtilService.fire(entity, new FireOption().setAgendaGroup("sign"));
		
		return entity;
	}
	@GetMapping("/rule/fire/tax")
	public Object ruleFireTax(Tax entity) {
		kieUtilService.fire(entity);
		
		return entity;
	}
	
	@Autowired
	private AppDroolsConfigPropertiesBean appDroolsConfigPropertiesBean;
	@GetMapping("/rule/config")
	public Object ruleConfig() {
		
		return appDroolsConfigPropertiesBean;
	}
}
